//定义全局变量
var CONF = {debug:true};
//定义调试函数
var debuger = function(obj){
	if(CONF['debug']){
		console.log(obj);
	}
};
var WEB_ROOT = 'http://localhost';
var LINK = "";
function getParam(){
	var param = location.search.trim();
	var returnMap = {};
		param = param.replace('?','');
		paramArr = param.split('#');
		returnMap['anchor'] = paramArr.length == 2?paramArr[1]:null;
		paramArr = param.split('&');
	var size = paramArr.length;
	var temp;
		for(var i=0;i<size;i++){
			temp = paramArr[i].trim().split("=");
			returnMap[temp[0]] = (temp.length == 2)?temp[1]:null;
		}
	return returnMap;
}
$(function(){
	var back = getParam()['backUrl'];
	if(back)$(".ekl_back").attr("href",back);
	$(window).resize(function(event){

	});
////.on('tap',function(event){
//////		event.stopPropagation();
//////		event.preventDefault();		
//////		alert(JSON.stringify(event));
////	});
//	$(document).on('touchend',function(){
//		event.stopPropagation();
//		event.preventDefault();	
////		alert('touc2');
//	}).on('tap',function(event){
//		event.stopPropagation();
//		event.preventDefault();	
////		alert(LINK);
////		if(LINK) location.href=LINK;
////		alert('DOC'+JSON.stringify(event));
////		alert('DOC'+JSON.stringify(event.target));
//	});
	//设置返回按钮动作
//	$(".ekl_back").on('tap',function(event){
//		event.stopPropagation();
//		event.preventDefault();
//		history.back();
//	});
	var moveNum = 0;
	$(".ekl_link").on('touchstart',function(e){
		e.stopPropagation();
//		e.preventDefault();		
		moveNum = 1;
	}).on('touchmove',function(e){
		e.stopPropagation();
//		e.preventDefault();		
		moveNum++;
//		event.href=$(this).attr("href");
//		var link = $(this).attr("href");
//		setTimeout(function(){
//			if(link){
////			LINK = $(this).attr("href");
//
//			location.href = link;
//		}
//		},150,null);
		
	}).on('touchend',function(e){
		e.stopPropagation();
		e.preventDefault();
		if(moveNum==1)
		{
			moveNum = 0;
			location.href = $(this).attr("href");
		}
	});
	var moveNum_ = 0;
	$(".ekl_back").on('touchstart',function(e){
		e.stopPropagation();
		e.preventDefault();		
		moveNum_ = 1;
	}).on('touchmove',function(e){
		e.stopPropagation();
//		e.preventDefault();		
		moveNum_++;
//		event.href=$(this).attr("href");
//		var link = $(this).attr("href");
//		setTimeout(function(){
//			if(link){
////			LINK = $(this).attr("href");
//
//			location.href = link;
//		}
//		},150,null);
		
	}).on('touchend',function(e){
		e.stopPropagation();
		e.preventDefault();
		if(moveNum_<=1)
		{
			moveNum_ = 0;
			history.back();
		}
	});	
//.on('touchend',function(event){
//		alert();
//		event.stopPropagation();
//		event.preventDefault();
//	});
});
//<div id="tipPopover" class="mui-popover">
//	<div class="mui-content-padded">
//		<h5 class="tip-title">提示</h5>
//		<div class="tip-content">请先选择~</div>
//</div>
//</div>
var ZK = window.ZK?window.ZK:function(){
		this.status = false;
		this.root = document.createElement("div");
		this.mui_content_padded = document.createElement("div");
		this.tip_title =  document.createElement("h5");
		this.tip_content = document.createElement("div");
		this.tip_content.setAttribute("class","tip-content");
		this.tip_title.setAttribute("class","tip-title");
		this.mui_content_padded.setAttribute("class","mui-content-padded");
	    this.root.setAttribute("id","tipPopover");
	    this.root.setAttribute("class","mui-popover");
	    this.root.appendChild(this.mui_content_padded);
	    this.mui_content_padded.appendChild(this.tip_title);
        this.mui_content_padded.appendChild(this.tip_content);
        document.body?document.body.appendChild(this.root):document.documentElement.appendChild(this.root);
};
ZK.prototype.toast = function(tip){
   this.tip_content.innerHTML = tip;	
   this.tip_title.innerHTML = "提示";	
   if(document.querySelector(".mui-popover").style.display=="block"){
   		
   }else{
   		mui('.mui-popover').popover('toggle');
   }
   		
}
var zk = new ZK();
 
